// pages/operator/index/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    background: [''],
    alertNum:1,

    popupFlag: false, // 晚上信息弹出层开关
    
    roleFlag: false, // 选择角色开关
    roleActions: [
      {  name: '经营主体', type: 1 },
      {  name: '批发商', type: 2 },
      {  name: '零售商', type: 3 },
    ],
    roleText: '请选择角色'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onReady() {
    this.getInfo()
  },
  // 日期格式化yyyy-mm-dd
  formatDate(date) {
    date = new Date(date);
    let year=date.getFullYear()+"-"
    let month=(date.getMonth()<10?"0"+(date.getMonth() + 1):date.getMonth() + 1)+"-"
    let day=(date.getDate()<10?"0"+date.getDate():date.getDate())
    return year+month+day;
  },
  // 获取详情
getInfo(){
  // 获取预警数量
  wx.$req({
    url: '/wms/monitor/getWarnLogListByMonitorId',
    method: 'post',
    data:{beginTime:this.formatDate(new Date())+" 00:00:00",endTime:this.formatDate(new Date())+" 23:59:59",status:"0"}
  }).then(res => {
    let num=res.data.content.length
    this.setData({ alertNum:num })
  })
},

  /**
   * 生命周期函数--监听页面显示
   */
  onshow() {
    this.getInfo()
  },

  // 展开完善信息弹窗
  openPopup () {
    this.setData({ popupFlag: true })
  },

  // 关闭完善信息弹窗
  onClose () {
    this.setData({ popupFlag: false })
  },

   // 展开选择角色面板
   openRole () {
    this.setData({ roleFlag: true })
  },

  // 选择角色面板回调
  roleSelect (e) {
    console.log(e.detail.name)
    this.setData({ 
      roleFlag: false,
      roleText: e.detail.name,
    })
  },

  // 前往查看更多
  toNotice () {
    wx.navigateTo({
      url: '/pages/notice/index',
    })
  },
  toIntelligentRecognition(){
    wx.navigateTo({
      url: '/pages/IntelligentRecognition/index',
    })
  },
  priceSystem(){
    wx.navigateTo({
      url: '/pages/priceSystem/index',
    })
  },
  // 风险告警
  toRisk () {
    wx.navigateTo({
      url: '/pages/riskAlarm/index',
    })
  },

  // 储存库
  toCold () {
    wx.navigateTo({
      url: '/pages/cold/index',
    })
  },

  // 设备
  toEquipment() {
    wx.navigateTo({
      url: '/pages/equipment/index',
    })
  },

  // 产销管理
  toMangae () {
    wx.navigateTo({
      url: '/pages/productionManage/index'
    })
  },

  // 储存库经营者
  toColdMangae () {
    wx.navigateTo({
      url: '/pages/coldManage/index'
    })
  },

  // 库存查询
  toWarehouseSearch () {
    wx.navigateTo({
      url: '/pages/warehouseSearch/index'
    })
  },

  // 库存管理
  toWarehouseManage () {
    wx.navigateTo({
      url: '/pages/warehouseManage/index'
    })
  }

})